package com.vgemv.jsutilitysdk.reflectservice;

import java.lang.reflect.Field;

public class GajKvcObject {
    public String strValueForKey(String key) {
        Field field = null;
        String strValue = null;
        try {
            field = this.getClass().getDeclaredField(key);
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        }
        try {
            strValue  = (String)field.get(this);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        return strValue;
    }

    public void setStrValueForKey(String key,String value) {
        Field field = null;
        String strValue = null;
        try {
            field = this.getClass().getDeclaredField(key);
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        }
        try {
            field.set(this,strValue);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}
